<template>
  <PromiseDialog ref="dialog"> <FormAddOrEdit :id="id" @suc="onSubmit" @fatal='onFatal' /> </PromiseDialog>
</template>
<script lang="ts">
import Vue from 'vue'
import PromiseDialog from '@/components/PromiseDialog.vue'
import FormAddOrEdit from './FormAddOrEdit.vue'
export default Vue.extend({
  name: 'DialogAddOrEditResource',
  components: {
    PromiseDialog,
    FormAddOrEdit
  },
  props: ['id'],
  methods: {
    open () {
      return (this.$refs.dialog as any).open()
    },
    onSubmit () {
      (this.$refs.dialog as any).resolve()
    },
    onFatal (message: any) {
      (this.$refs.dialog as any).reject(message)
    }
  }
})
</script>
